package com.spider.moudle.handler;

import com.spider.moudle.consumer.StartardConsumer;
import com.spider.moudle.entity.Setting;
import com.spider.moudle.util.CenterExecutorUtil;
import com.spider.moudle.util.SettingsUtil;

import java.util.List;

/**
 * Created by Linbo Hu on 2017/11/29.
 * 消费者处理器
 */
public class ConsumerHandler {

    /**
     * 消费者处理器方法
     */
    public static void handle() {
        List<Setting> settingList = SettingsUtil.getAllSettingList();
        for(Setting setting : settingList) {
            Boolean spider_is_worked = setting.getSpider_is_worked();
            if(spider_is_worked) {
                CenterExecutorUtil.execute(new StartardConsumer(setting));
            } else {
                System.err.println("===  消费者：" + setting.getSite() + " 未加入主线程  ===");
            }
        }
    }
}
